package com.android.kotlin.fragment

import android.support.v4.app.Fragment
import android.support.v4.app.FragmentManager
import android.support.v4.app.FragmentPagerAdapter

/**
 * @Description:
 * @Author: xuwenlong
 * @Email: xuwenlong @ebrun.com
 * @Version:
 * @Create: 2019/2/28 0028
 * @Modify:
 */

class FragmentFactory(fm: FragmentManager) :FragmentPagerAdapter(fm){


    override fun getItem(res: Int): Fragment {
        var fragment: Fragment? = null
        when (res) {
            0 -> fragment = HomeFragment()
            1 -> {
                fragment = WeChatFragment()
            }
            2 -> fragment = GrilFragment()
            3 -> fragment = NavigationFragment()
            4 -> fragment = ProjectFragment()
            else -> {
                fragment = GrilFragment()
            }
        }

        return fragment!!;
    }

    override fun getCount(): Int {
        return 5
    }
}